﻿using System;
using Atm.BLL;

public partial class usercontrols_ucContact : HocLapTrinhWeb.UI.UCBase
{
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
    }

    public void ClearText()
    {
        txtUsername.Text = string.Empty;
        txtEmail.Text = string.Empty;
        txtPhone.Text = string.Empty;
        txtAddress.Text = string.Empty;
        txtTitle.Text = string.Empty;
        txtContent.Text = string.Empty;
    }

    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            var contactBll = new ContactBLL(CurrentPage.getCurrentConnection());
            var dt = new dsAtm.tbl_ContactDataTable();
            var row = dt.Newtbl_ContactRow();
            row.UserName = txtUsername.Text;
            row.Email = txtEmail.Text;
            row.Phone = txtPhone.Text;
            row.Address = txtAddress.Text;
            row.Title = txtTitle.Text;
            row.Content = txtContent.Text;
            row.CreatedDate = DateTime.Now;
            row.Type = 1;
            row.Status = 0;
            row.CreatedDate = DateTime.Now;
            dt.Addtbl_ContactRow(row);
            if (!contactBll.Add(dt)) return;
            ClearText();
            SaveValidate1.IsValid = false;
            SaveValidate1.ErrorMessage = "Gửi liên hệ thành công!";
        }
        catch (Exception)
        {
            SaveValidate1.IsValid = false;
            SaveValidate1.ErrorMessage = "Gửi không thành công!";
        }
    }

}
